<template>
	<view class="page">
    <view class="tcard">
      <!-- <tki-qrcode
      	ref="qrcode"
      	onval
      	:val="userInfo.patId"
      	:size="400"
      	:load-make="true"
      	:show-loading="false"/> -->
      <tki-barcode
      	ref="barcode"
      	onval
      	:val="userInfo.patId || '123'"
      	:load-make="true"
      	:opations="barOpations"/>
      <view style="text-align: center;margin-top: 12upx;">
        病历号{{userInfo.patId || '123'}}
      </view>
    </view>
		<view v-for="(item,index) in listData" :key="index" class="tcard">
			<view class="card-row" v-for="cItem in cardLabel" :key='cItem.fKey' :style="{color:item.unit=='元'?orageColor:''}">
        <label>{{cItem.label}}</label>
        {{item[cItem.key]|| cItem.label.replace('：','') + '数据'}}
      </view>
		</view>
		<Load :load="load"></Load>
	</view>
</template>

<script>
	import Load from '@/components/Load/index.vue'
	import { getPayDetail, getPayDetails } from '@/api/home.js'
	import { orageColor } from '@/static/js/theme.js'
  import { mapActions, mapGetters } from 'vuex';
  import tkiBarcode from '@/components/BarCode/tki-barcode.vue'
  
	export default {
		components: { Load, tkiBarcode },
		data() {
			return {
				listData:[{},{}],
        barOpations:{
        	displayValue:false
        },
				cardLabel:[
					{
						label:'项目名称：',
						key:'ypmc',
						fKey:'label11',
						unit:''
					},
					{
						label:'项目数量：',
						key:'ypsl',
						fKey:'label21',
						unit:''
					},
					{
						label:'项目单价：',
						key:'ypdj',
						fKey:'label31',
						unit:'元'
					},
					{
						label:'项目规格：',
						key:'gg',
						fKey:'label41',
						unit:''
					},
					{
						label:'项目金额：',
						key:'zje',
						fKey:'label51',
						unit:'元'
					}
				],
				load:false,
				jssjh:null,
				cfxh:null
			}
		},
    computed:{
      ...mapGetters(['userInfo','userId','userList']),
    },
		onLoad(op) {
			if(op.jssjh){
				// 从我的缴费页面过来
				this.jssjh = op.jssjh 
			}
			if(op.cfxh){
				// 从处方缴费过来
				this.cfxh = op.cfxh
			}
			// this.initData()
		},
		methods: {
			initData(){
				this.load = true
				let params = {}
				if(this.jssjh){
					params.jssjh = this.jssjh
					getPayDetail(params).then(data => {
						this.load = false
						this.listData = data||[]
					}).catch(e => {
						this.listData = []
						this.load = false
					})
				}else if(this.cfxh){
					params.cfxh = this.cfxh
					getPayDetails(params).then(data => {
						this.load = false
						this.listData = data||[]
					}).catch(e => {
						this.listData = []
						this.load = false
					})
				}
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.outpatient-serve-detail{
		height: calc(100vh);
		overflow: scroll;
		background-color: $uni-bg-color;
		&-main{
			padding-top: 30rpx;
			>.card-row{
				padding: 0 30rpx;
			}
			>.div-cut{
				margin: 20rpx 0;
			}
		}
	}
</style>